package health.lm.com.home.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.vondear.rxtool.RxDataTool;
import com.vondear.rxtool.RxTimeTool;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.home.R;
import health.lm.com.home.entity.NoticesEntity;

/**
 * Created by Android Studio .
 * Project：hlian health.lm.com.home.adapter
 * Date：2019/8/7 17:11
 * Introduce：通知消息
 */
public class NoticesAdapter extends BaseQuickAdapter<NoticesEntity, BaseViewHolder> {
    public NoticesAdapter(@Nullable List<NoticesEntity> data) {
        super(R.layout.fragment_notices_item, data);
    }

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper A fully initialized helper.
     * @param item   The item that needs to be displayed.
     */
    @Override
    protected void convert(BaseViewHolder helper, NoticesEntity item) {
        String time = "";
        try {
            time = RxTimeTool.date2String(new Date(Long.parseLong(item.getTime()) * 1000));
        } catch (NumberFormatException pE) {
            pE.printStackTrace();
        }
        helper.setGone(R.id.textView2, item.getIsReadd() == 1)
                .setText(R.id.textView, time)
                .setText(R.id.textView3, item.getTitle())
                .setText(R.id.textView4, item.getNewsletter())
        ;

        //ImageLoaderHelper.getInstance().load(mContext,item.getImage(),helper.getView(R.id.imageView3));
    }
}
